# coding: utf-8
# Macro created by MSC Apex 2024.2 PRE - Version CLR:012340-32099e62
# Macro created on Aug 01, 2024 at 14:35:32
# 
# Macro Name = 
# 
# Macro Description = 
# 
# Macro Hot Key = 
# 
# Initialize environment for macro execution
# 

import apex
from apex.construct import Point3D, Point2D

apex.setScriptUnitSystem(unitSystemName = r'''mm-kg-s-N-K''')
applicationSettingsGeometry = apex.setting.ApplicationSettingsGeometry()
applicationSettingsGeometry.createGeometryInNewPart = apex.setting.CreateGeometryInNewPart.CurrentPart
applicationSettingsGeometry.geometryTessellationIsWatertight = False
applicationSettingsGeometry.geometryEdgeTesselationTolerance = apex.setting.GeometryTessellationTolerance.Medium
applicationSettingsGeometry.geometryFaceTesselationTolerance = apex.setting.GeometryTessellationTolerance.Medium
apex.setting.setApplicationSettingsGeometry(applicationSettingsGeometry = applicationSettingsGeometry)
applicationSettingsStudy = apex.setting.ApplicationSettingsStudy(useNewScenario = True,displayPrereleaseScenario = False,displayUnsupportedCommand = False)
apex.setting.setApplicationSettingsStudy(applicationSettingsStudy = applicationSettingsStudy)
model_1 = apex.currentModel()

# 
# Start of recorded operations
# 

def doSketch_1():
    part_1 = model_1.getCurrentPart()
    if part_1 is None:
        part_1 = model_1.createPart()
    sketch_1 = part_1.createSketchOnGlobalPlane(
        name = 'Sketch 1',
        plane = apex.construct.GlobalPlane.XY,
        alignSketchViewWithViewport = True
    )


    rectangle_1 = sketch_1.createRectangle2Point(
        name = "Rectangle 1",
        location = Point2D( 0.0, 0.0 ),
        diagonal = Point2D( 2.000000000000000e+01, 2.000000000000000e+01 )
    )

    return sketch_1.completeSketch( fillSketches = True )

newbodies = doSketch_1()


_target = apex.EntityCollection()
part_2 = apex.getPart( pathName = apex.currentModel().name + "/Part 1" )
surface_1 = part_2.getSurface( name = "Surface 1" )
_ids = '1'
_target.extend( surface_1.getFaces( ids = _ids ) )
result = apex.geometry.pushPull(
    target = _target,
    method = apex.geometry.PushPullMethod.Normal,
    behavior = apex.geometry.PushPullBehavior.Extrude,
    removeInnerLoops = False,
    createBooleanUnion = False,
    distance = 2.000000000000000e+01,
    direction = [ 0.0, 0.0, 1.000000000000000 ]
)

part_3 = apex.createPart()

def doSketch_2():
    part_3 = model_1.getCurrentPart()
    if part_3 is None:
        part_3 = model_1.createPart()
    sketch_2 = part_3.createSketchOnGlobalPlane(
        name = 'Sketch 2',
        plane = apex.construct.GlobalPlane.XY,
        alignSketchViewWithViewport = True
    )


    rectangle_2 = sketch_2.createRectangle2Point(
        name = "Rectangle 2",
        location = Point2D( -2.000000000000000e+01, 2.000000000000000e+01 ),
        diagonal = Point2D( 2.000000000000000e+01, 0.0 )
    )

    return sketch_2.completeSketch( fillSketches = True )

newbodies = doSketch_2()


part_4 = apex.createPart()

assembly_1 = apex.createAssembly()

entities_3 = apex.EntityCollection()
entities_1 = apex.EntityCollection()
entities_1.append(part_3)
entities_3.extend( entities_1 )
entities_2 = apex.EntityCollection()
entities_2.append(part_4)
entities_3.extend( entities_2 )
apex.reparent( parent = assembly_1, target = entities_3 )

def doSketch_3():
    part_4 = model_1.getCurrentPart()
    if part_4 is None:
        part_4 = model_1.createPart()
    sketch_3 = part_4.createSketchOnGlobalPlane(
        name = 'Sketch 3',
        plane = apex.construct.GlobalPlane.ZX,
        alignSketchViewWithViewport = True
    )


    _pointList = [
        Point2D( 0.0, 0.0 ),
        Point2D( 0.0, 4.000000000000000e+01 )
    ]
    polyline_1 = sketch_3.createPolyline(
        name = "Polyline 1",
        points = _pointList
    )

    _pointList = [
        Point2D( 0.0, 4.000000000000000e+01 ),
        Point2D( -2.000000000000000e+01, 4.000000000000000e+01 )
    ]
    polyline_2 = sketch_3.createPolyline(
        name = "Polyline 2",
        points = _pointList
    )

    _pointList = [
        Point2D( -2.000000000000000e+01, 4.000000000000000e+01 ),
        Point2D( -2.000000000000000e+01, 0.0 )
    ]
    polyline_3 = sketch_3.createPolyline(
        name = "Polyline 3",
        points = _pointList
    )

    _sketchEdge = sketch_3.getEdge( id = 2141 )
    result = _sketchEdge.update( length = 4.000000000000000 )

    _edge1 = sketch_3.getEdge( id = 11 )
    sketch_3.trimCurve(
        edge1 = _edge1,
        point = Point2D( -1.123841293156147e+01, 2.344130352139473e+01 )
    )

    _pointList = [
        Point2D( -4.000000000000000, 4.000000000000000e+01 ),
        Point2D( -4.000000000000000, 0.0 )
    ]
    polyline_4 = sketch_3.createPolyline(
        name = "Polyline 4",
        points = _pointList
    )

    return sketch_3.completeSketch( fillSketches = True )

newbodies = doSketch_3()


_entities = apex.currentModel().getEntities(pathNames=["Assembly 1/Part 3/Curve 1"])
newEntities = apex.transformTranslate(
    target = _entities,
    direction = [ 0.0, 1.000000000000000, 0.0 ],
    distance = 2.000000000000000e+01,
    makeCopy = True
)

_target = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
curve_1 = part_5.getCurve( name = "Curve 1 (2)" )
_ids = '52'
_target.extend( curve_1.getEdges( ids = _ids ) )
curve_2 = part_5.getCurve( name = "Curve 1" )
_ids = '42'
_target.extend( curve_2.getEdges( ids = _ids ) )
_iphysicalCollection = apex.ILocationCollection() 
result = apex.geometry.fillerSurface( target = _target, 
    locations = _iphysicalCollection,
    retainReferenceCurveEdges = False )

_target = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
curve_1 = part_5.getCurve( name = "Curve 1 (2)" )
_ids = '53'
_target.extend( curve_1.getEdges( ids = _ids ) )
curve_2 = part_5.getCurve( name = "Curve 1" )
_ids = '43'
_target.extend( curve_2.getEdges( ids = _ids ) )
_iphysicalCollection = apex.ILocationCollection() 
result = apex.geometry.fillerSurface( target = _target, 
    locations = _iphysicalCollection,
    retainReferenceCurveEdges = False )

_target = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
curve_1 = part_5.getCurve( name = "Curve 1 (2)" )
_ids = '51'
_target.extend( curve_1.getEdges( ids = _ids ) )
curve_2 = part_5.getCurve( name = "Curve 1" )
_ids = '41'
_target.extend( curve_2.getEdges( ids = _ids ) )
_iphysicalCollection = apex.ILocationCollection() 
result = apex.geometry.fillerSurface( target = _target, 
    locations = _iphysicalCollection,
    retainReferenceCurveEdges = False )

_entities = apex.currentModel().getEntities(pathNames=["Part 1/Solid 1"])
newEntities = apex.transformTranslate(
    target = _entities,
    direction = [ 0.0, 0.0, 1.000000000000000 ],
    distance = 1.000000000000000,
    makeCopy = False
)

_target = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_6 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 2" )
surface_2 = part_6.getSurface( name = "Surface 2" )
_geoms.append( surface_2 )
_target.extend( _geoms )
thicknessoffsetfieldconstant_1 = apex.attribute.createFieldThicknessOffsetConstant( type = apex.attribute.DiscreteFEMFieldType.DiscreteThicknessField, name = "Thickness field", targets = _target, constantValue = 1.)

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.Wireframe )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.ShadedWithEdges )

_target = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_6 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 2" )
surface_2 = part_6.getSurface( name = "Surface 2" )
_geoms.append( surface_2 )
_target.extend( _geoms )
thicknessoffsetfieldconstant_2 = apex.attribute.createFieldThicknessOffsetConstant( type = apex.attribute.DiscreteFEMFieldType.DiscreteOffsetField, name = "Offset field", targets = _target, constantValue = 0.5)

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.Wireframe )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.ShadedWithEdges )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.Wireframe )

result = apex.session.display3DSpans( False )

result = apex.session.display3DSpans( True )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.ShadedWithEdges )

_target = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
surface_3 = part_5.getSurface( name = "Surface 3" )
_geoms.append( surface_3 )
_target.extend( _geoms )
thicknessoffsetfieldconstant_3 = apex.attribute.createFieldThicknessOffsetConstant( type = apex.attribute.DiscreteFEMFieldType.DiscreteThicknessField, name = "Thickness field", targets = _target, constantValue = 2.)

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.Wireframe )

_target = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
surface_3 = part_5.getSurface( name = "Surface 3" )
_geoms.append( surface_3 )
_target.extend( _geoms )
thicknessoffsetfieldconstant_4 = apex.attribute.createFieldThicknessOffsetConstant( type = apex.attribute.DiscreteFEMFieldType.DiscreteOffsetField, name = "Offset field", targets = _target, constantValue = -1.)

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.ShadedWithEdges )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.Wireframe )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.ShadedWithEdges )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.Wireframe )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.ShadedWithEdges )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.Wireframe )

solid_1 = apex.getSolid( pathName = apex.currentModel().name+"/Part 1/Solid 1" )
solid_1.update( renderStyle = apex.session.DisplayRenderStyle.ShadedWithEdges )

_target = apex.EntityCollection()
part_6 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 2" )
surface_2 = part_6.getSurface( name = "Surface 2" )
_target.append( surface_2 )
featuremeshtypes_1 = apex.mesh.FeatureMeshTypeVector()
result = apex.mesh.createSurfaceMesh(
    name = "",
    target = _target,
    meshSize = 10.,
    meshType = apex.mesh.SurfaceMeshElementShape.Mixed,
    meshMethod = apex.mesh.SurfaceMeshMethod.Auto,
    mappedMeshDominanceLevel = 2,
    elementOrder = apex.mesh.ElementOrder.Linear,
    allQuadBoundary = False,
    applyTriaReduction = False,
    triaReductionStrength = 2,
    refineMeshUsingCurvature = False,
    curvatureType = apex.mesh.CurvatureType.EdgeAndFace,
    elementGeometryDeviationRatio = 0.10,
    elementMinEdgeLengthRatio = 0.20,
    proximityRefinement = False,
    growFaceMeshSize = False,
    faceMeshGrowthRatio = 1.2,
    createFeatureMeshes = False,
    featureMeshTypes = featuremeshtypes_1,
    projectMidsideNodesToGeometry = True,
    useMeshFlowOptimization = True,
    meshFlow = apex.mesh.MeshFlow.Grid,
    minimalMesh = False
)

_target = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
surface_3 = part_5.getSurface( name = "Surface 3" )
_target.append( surface_3 )
featuremeshtypes_2 = apex.mesh.FeatureMeshTypeVector()
result = apex.mesh.createSurfaceMesh(
    name = "",
    target = _target,
    meshSize = 10.,
    meshType = apex.mesh.SurfaceMeshElementShape.Mixed,
    meshMethod = apex.mesh.SurfaceMeshMethod.Auto,
    mappedMeshDominanceLevel = 2,
    elementOrder = apex.mesh.ElementOrder.Linear,
    allQuadBoundary = False,
    applyTriaReduction = False,
    triaReductionStrength = 2,
    refineMeshUsingCurvature = False,
    curvatureType = apex.mesh.CurvatureType.EdgeAndFace,
    elementGeometryDeviationRatio = 0.10,
    elementMinEdgeLengthRatio = 0.20,
    proximityRefinement = False,
    growFaceMeshSize = False,
    faceMeshGrowthRatio = 1.2,
    createFeatureMeshes = False,
    featureMeshTypes = featuremeshtypes_2,
    projectMidsideNodesToGeometry = True,
    useMeshFlowOptimization = True,
    meshFlow = apex.mesh.MeshFlow.Grid,
    minimalMesh = False
)

_target = apex.EntityCollection()
part_2 = apex.getPart( pathName = apex.currentModel().name + "/Part 1" )
solid_1 = part_2.getSolid( name = "Solid 1" )
_target.append( solid_1 )
_SweepFace = apex.EntityCollection()
result = apex.mesh.createHexMesh(
    name = "",
    target = _target,
    meshSize = 10.,
    surfaceMeshMethod = apex.mesh.SurfaceMeshMethod.Auto,
    mappedMeshDominanceLevel = 2,
    elementOrder = apex.mesh.ElementOrder.Linear,
    refineMeshUsingCurvature = False,
    elementGeometryDeviationRatio = 0.10,
    elementMinEdgeLengthRatio = 0.20,
    createFeatureMeshOnWashers = False,
    createFeatureMeshOnArbitraryHoles = False,
    preserveWasherThroughMesh = True,
    sweepFace = _SweepFace,
    hexMeshMethod = apex.mesh.HexMeshMethod.Auto,
    projectMidsideNodesToGeometry = True
)

material_1 = apex.catalog.createMaterial(
    name = 'Material 1',
    color = [ 0, 0, 0 ],
    primaryMaterialModel = 'MAT1',
)

matModel_ = material_1.getMaterialModel( materialModel = 'MAT1')
matModel_.update( materialProperties = {
    'E' : 200000.,
    })

matModel_ = material_1.getMaterialModel( materialModel = 'MAT1')
matModel_.update( materialProperties = {
    'NU' : 0.3,
    })

material_2 = apex.catalog.createMaterial(
    name = 'Material 2',
    color = [ 0, 0, 0 ],
    primaryMaterialModel = 'MAT1',
)

matModel_ = material_2.getMaterialModel( materialModel = 'MAT1')
matModel_.update( materialProperties = {
    'E' : 178000.,
    })

matModel_ = material_2.getMaterialModel( materialModel = 'MAT1')
matModel_.update( materialProperties = {
    'NU' : 0.25,
    })

propertyelement3d_1 = apex.catalog.createPropertiesElement3D(
    name = '3D Element Property 1',
    primaryProperties3D = 'PSOLID',
)

propertyelement3d_1 = apex.catalog.getPropertiesElement3D( name = "3D Element Property 1" )
property3DModel_ = propertyelement3d_1.getProperties3DModel( properties3DModel = 'PSOLID')
property3DModel_.update( elementProperties3D = {
    'MID' : 1,
    })

_target = apex.EntityCollection()
entities_4 = apex.EntityCollection()
mesh_1 = apex.getHexMesh( pathName = apex.currentModel().name + "/Part 1/Mesh 3" )
entities_4.append(mesh_1)
_target += entities_4
apex.attribute.assignPropertiesElement3D(target = _target, property = propertyelement3d_1 )

propertyelement2d_1 = apex.catalog.createPropertiesElement2D(
    name = '2D Element Property 1',
    primaryProperties2D = 'PSHELL',
)

propertyelement2d_1 = apex.catalog.getPropertiesElement2D( name = "2D Element Property 1" )
property2DModel_ = propertyelement2d_1.getProperties2DModel( properties2DModel = 'PSHELL')
property2DModel_.update( elementProperties2D = {
    'MID1' : 2,
    })

_target = apex.EntityCollection()
entities_6 = apex.EntityCollection()
mesh_2 = apex.getSurfaceMesh( pathName = apex.currentModel().name + "/Assembly 1/Part 2/Mesh 1" )
entities_6.append(mesh_2)
_target += entities_6
apex.attribute.assignProperty2D( property2d = propertyelement2d_1, target = _target )

propertyelement2d_2 = apex.catalog.createPropertiesElement2D(
    name = '2D Element Property 2',
    primaryProperties2D = 'PSHELL',
)

propertyelement2d_2 = apex.catalog.getPropertiesElement2D( name = "2D Element Property 2" )
property2DModel_ = propertyelement2d_2.getProperties2DModel( properties2DModel = 'PSHELL')
property2DModel_.update( elementProperties2D = {
    'MID1' : 2,
    })

_target = apex.EntityCollection()
entities_7 = apex.EntityCollection()
mesh_3 = apex.getSurfaceMesh( pathName = apex.currentModel().name + "/Assembly 1/Part 3/Mesh 2" )
entities_7.append(mesh_3)
_target += entities_7
apex.attribute.assignProperty2D( property2d = propertyelement2d_2, target = _target )

#############################
apex.beginUndoIndent()

_target = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
surface_3 = part_5.getSurface( name = "Surface 3" )
_ids = '1111'
_geoms.extend( surface_3.getFaces( ids = _ids ) )
_target.extend( _geoms )

constraintsinglepoint_1 = apex.environment.createConstraintSinglePoint(
    name = "Constraint",
    constrainTranslationX = True,
    constrainTranslationY = True,
    constrainTranslationZ = True,
    constrainRotationX = True,
    constrainRotationY = True,
    constrainRotationZ = True,
    target = _target,
    constraintType = apex.attribute.ConstraintType.Clamped
)

apex.endUndoIndent(description='Created Constraint 1')
#############################

matModel_ = material_2.getMaterialModel( materialModel = 'MAT1')
matModel_.update( materialProperties = {
    'RHO' : 0.000006,
    })

matModel_ = material_1.getMaterialModel( materialModel = 'MAT1')
matModel_.update( materialProperties = {
    'RHO' : 0.000008,
    })

#############################
apex.beginUndoIndent()

_target = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_6 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 2" )
surface_2 = part_6.getSurface( name = "Surface 2" )
_ids = '31'
_geoms.extend( surface_2.getEdges( ids = _ids ) )
_target.extend( _geoms )

constraintsinglepoint_2 = apex.environment.createConstraintSinglePoint(
    name = "Constraint",
    constrainTranslationX = True,
    constrainTranslationY = True,
    constrainTranslationZ = True,
    constrainRotationX = True,
    constrainRotationY = True,
    constrainRotationZ = True,
    target = _target,
    constraintType = apex.attribute.ConstraintType.Clamped
)

apex.endUndoIndent(description='Created Constraint 2')
#############################

#############################
apex.beginUndoIndent()

_combinedConstraints = apex.EntityCollection()
_combinedConstraints.append(apex.environment.getConstraint(name = "Constraint 1"))
_combinedConstraints.append(apex.environment.getConstraint(name = "Constraint 2"))

constraintcombination_1 = apex.environment.createConstraintCombination(
    name = "Constraint Combination",
    combinedConstraints = _combinedConstraints
)

apex.endUndoIndent(description='Created Constraint Combination 1')
#############################

orientation_ = apex.construct.createOptionOrientation()
orientation_.GlobalNZ = True
gravity_1 = apex.environment.createGravityByG(
    name = "Gravity",
    gravConstant = 9806.65,
    orientation = orientation_,
    gravConstantMultiplier = 1.0,
    description = "",   #defaults to " "
    coordinateSystemDefinition = 0
)

apex.beginUndoIndent()
_body1Property = apex.attribute.createContactBodyProperty(
    smoothingState = False,
)
_body2Property = apex.attribute.createContactBodyProperty(
    smoothingState = False,
)
_interactionPropertyGeometric = apex.attribute.createInteractionPropertyGeometric(
    contactToleranceCalculationMethod = apex.AutoManual.Manual ,
    contactTolerance = 0.1,
    ignoreShellThicknessSide1 = False,
    shellLayerSide1 = apex.attribute.ShellLayer.TopAndButtom,
    ignoreShellThicknessSide2 = False,
    shellLayerSide2 = apex.attribute.ShellLayer.TopAndButtom,
    contactSearchOrder = apex.attribute.ContactSearchOrder.DoubleSide,
    stressFreeInitialContact = False,
    delayedSlideOff = False,
    interferenceFit = False,
    initialClearance = False,
)
_interactionPropertyPhysical = apex.attribute.createInteractionPropertyPhysical(
    frictionCoefficient = 0.3,
)
_sideTarget1 = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_6 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 2" )
surface_2 = part_6.getSurface( name = "Surface 2" )
_geoms.append( surface_2 )
_sideTarget1.extend( _geoms )
_sideTarget2 = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_2 = apex.getPart( pathName = apex.currentModel().name + "/Part 1" )
solid_1 = part_2.getSolid( name = "Solid 1" )
_ids = '1'
_geoms.extend( solid_1.getFaces( ids = _ids ) )
_sideTarget2.extend( _geoms )
interaction_1 = apex.attribute.createInteractionManualPair(
    name = 'Interaction',
    description = '',
    targetSide1 = _sideTarget1,
    targetSide2 = _sideTarget2,
    body1Property = _body1Property,
    body2Property = _body2Property,
)
_activeRep = interaction_1.createInteractionRep(
    name = 'Interaction',
    description = '',
    interactionType = apex.attribute.InteractionType.GeneralContact,
    interactionPropertyGeometric = _interactionPropertyGeometric,
    interactionPropertyPhysical = _interactionPropertyPhysical,
    allowSelfContactSide1 = False,
    allowSelfContactSide2 = False,
)
apex.endUndoIndent(description="created contact")

apex.beginUndoIndent()
_body1Property = apex.attribute.createContactBodyProperty(
    smoothingState = False,
)
_body2Property = apex.attribute.createContactBodyProperty(
    smoothingState = False,
)
_interactionPropertyGeometric = apex.attribute.createInteractionPropertyGeometric(
    contactToleranceCalculationMethod = apex.AutoManual.Manual ,
    contactTolerance = 0.01,
    ignoreShellThicknessSide1 = False,
    shellLayerSide1 = apex.attribute.ShellLayer.TopAndButtom,
    ignoreShellThicknessSide2 = False,
    shellLayerSide2 = apex.attribute.ShellLayer.TopAndButtom,
    contactSearchOrder = apex.attribute.ContactSearchOrder.DoubleSide,
    stressFreeInitialContact = False,
    delayedSlideOff = False,
    interferenceFit = False,
    initialClearance = False,
)
_interactionPropertyPhysical = apex.attribute.createInteractionPropertyPhysical(
    frictionCoefficient = 0.32,
)
_sideTarget1 = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_6 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 2" )
surface_2 = part_6.getSurface( name = "Surface 2" )
_geoms.append( surface_2 )
_sideTarget1.extend( _geoms )
_sideTarget2 = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
surface_3 = part_5.getSurface( name = "Surface 3" )
_ids = '81'
_geoms.extend( surface_3.getFaces( ids = _ids ) )
_sideTarget2.extend( _geoms )
interaction_2 = apex.attribute.createInteractionManualPair(
    name = 'Interaction',
    description = '',
    targetSide1 = _sideTarget1,
    targetSide2 = _sideTarget2,
    body1Property = _body1Property,
    body2Property = _body2Property,
)
_activeRep = interaction_2.createInteractionRep(
    name = 'Interaction',
    description = '',
    interactionType = apex.attribute.InteractionType.GeneralContact,
    interactionPropertyGeometric = _interactionPropertyGeometric,
    interactionPropertyPhysical = _interactionPropertyPhysical,
    allowSelfContactSide1 = False,
    allowSelfContactSide2 = False,
)
apex.endUndoIndent(description="created contact")

apex.beginUndoIndent()
_body1Property = apex.attribute.createContactBodyProperty(
    smoothingState = False,
)
_body2Property = apex.attribute.createContactBodyProperty(
    smoothingState = False,
)
_interactionPropertyGeometric = apex.attribute.createInteractionPropertyGeometric(
    contactToleranceCalculationMethod = apex.AutoManual.Manual ,
    contactTolerance = 0.001,
    ignoreShellThicknessSide1 = False,
    shellLayerSide1 = apex.attribute.ShellLayer.TopAndButtom,
    ignoreShellThicknessSide2 = False,
    shellLayerSide2 = apex.attribute.ShellLayer.TopAndButtom,
    contactSearchOrder = apex.attribute.ContactSearchOrder.DoubleSide,
    stressFreeInitialContact = False,
    delayedSlideOff = False,
    interferenceFit = False,
    initialClearance = False,
)
_interactionPropertyPhysical = apex.attribute.createInteractionPropertyPhysical(
    frictionCoefficient = 0.33,
)
_sideTarget1 = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
surface_3 = part_5.getSurface( name = "Surface 3" )
_geoms.append( surface_3 )
_sideTarget1.extend( _geoms )
_sideTarget2 = apex.EntityCollection()
_geoms = apex.EntityCollection()
part_5 = apex.getPart( pathName = apex.currentModel().name + "/Assembly 1/Part 3" )
surface_3 = part_5.getSurface( name = "Surface 3" )
_geoms.append( surface_3 )
_sideTarget2.extend( _geoms )
interaction_3 = apex.attribute.createInteractionManualPair(
    name = 'Interaction',
    description = '',
    targetSide1 = _sideTarget1,
    targetSide2 = _sideTarget2,
    body1Property = _body1Property,
    body2Property = _body2Property,
)
_activeRep = interaction_3.createInteractionRep(
    name = 'Interaction',
    description = '',
    interactionType = apex.attribute.InteractionType.SelfContact,
    interactionPropertyGeometric = _interactionPropertyGeometric,
    interactionPropertyPhysical = _interactionPropertyPhysical,
    allowSelfContactSide1 = False,
    allowSelfContactSide2 = False,
)
apex.endUndoIndent(description="created contact")

#############################
apex.beginUndoIndent()

interactions_1 = apex.attribute.InteractionCollection()
# interaction1 = apex.attribute.getInteraction( pathName = apex.currentModel().name + '/Interaction 1' )
# interactions_1.append(interaction1)
interaction1 = apex.attribute.getInteraction( pathName = apex.currentModel().name + '/Assembly 1/Interaction 2' )
interactions_1.append(interaction1)
interaction1 = apex.attribute.getInteraction( pathName = apex.currentModel().name + '/Assembly 1/Part 3/Interaction 3' )
interactions_1.append(interaction1)
contacttable_1 = apex.attribute.createContactTable(name = 'Contact Table 1', id = 0, interactions = interactions_1)

apex.endUndoIndent(description='Created Contact Table 1')
#############################

#############################
apex.beginUndoIndent()

interactions_2 = apex.attribute.InteractionCollection()
# interaction1 = apex.attribute.getInteraction( pathName = apex.currentModel().name + '/Interaction 1' )
# interactions_2.append(interaction1)
interaction1 = apex.attribute.getInteraction( pathName = apex.currentModel().name + '/Assembly 1/Interaction 2' )
interactions_2.append(interaction1)
contacttable_2 = apex.attribute.createContactTable(name = 'Contact Table 2', id = 1, interactions = interactions_2)

apex.endUndoIndent(description='Created Contact Table 2')
#############################

# 
# Macro recording stopped on Aug 01, 2024 at 14:57:19
# 
